package com.atelier.plugin.projectWizard.util;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class FileContentReplacer {
    public static void replaceStringInFile(String filePath, String targetString, String replacement) throws IOException {
        // 读取文件内容
        Path path = Path.of(filePath);
        String content = Files.readString(path, StandardCharsets.UTF_8);

        // 替换目标字符串
        String modifiedContent = content.replace(targetString, replacement);

        // 将修改后的内容写回文件
        Files.writeString(path, modifiedContent, StandardCharsets.UTF_8);
    }
}
